home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / TURBOPASCAL WIN / DOCDEMOS.PAK / STEP02.PAS < prev    next >
Pascal/Delphi Source File  |  1992-06-08  |  2KB  |  75 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Demo program                                 }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. program MyProgram;
  10.  
  11. uses WinTypes, WinProcs, WObjects;
  12.  
  13. type
  14.   TMyApplication = object(TApplication)
  15.     procedure InitMainWindow; virtual;
  16.   end;
  17.  
  18. type
  19.   PMyWindow = ^TMyWindow;
  20.   TMyWindow = object(TWindow)
  21.     function CanClose: Boolean; virtual;
  22.     procedure WMLButtonDown(var Msg: TMessage);
  23.       virtual wm_First + wm_LButtonDown;
  24.     procedure WMRButtonDown(var Msg: TMessage);
  25.       virtual wm_First + wm_RButtonDown;
  26.   end;
  27.  
  28. {--------------------------------------------------}
  29. { TMyWindow's method implementations:              }
  30. {--------------------------------------------------}
  31.  
  32. function TMyWindow.CanClose: Boolean;
  33. var
  34.   Reply: Integer;
  35. begin
  36.   CanClose := True;
  37.   Reply := MessageBox(HWindow, 'Do you want to save?',
  38.     'Drawing has changed', mb_YesNo or mb_IconQuestion);
  39.   if Reply = id_Yes then CanClose := False;
  40. end;
  41.  
  42. procedure TMyWindow.WMLButtonDown(var Msg: TMessage);
  43. begin
  44.   MessageBox(HWindow, 'You have pressed the left mouse button',
  45.     'Message Dispatched', mb_Ok);
  46. end;
  47.  
  48. procedure TMyWindow.WMRButtonDown(var Msg: TMessage);
  49. begin
  50.   MessageBox(HWindow, 'You have pressed the right mouse button',
  51.     'Message Dispatched', mb_Ok);
  52. end;
  53.  
  54. {--------------------------------------------------}
  55. { TMyApplication's method implementations:         }
  56. {--------------------------------------------------}
  57.  
  58. procedure TMyApplication.InitMainWindow;
  59. begin
  60.   MainWindow := New(PMyWindow, Init(nil, 'Sample ObjectWindows Program'));
  61. end;
  62.  
  63. {--------------------------------------------------}
  64. { Main program:                                    }
  65. {--------------------------------------------------}
  66.  
  67. var
  68.   MyApp: TMyApplication;
  69.  
  70. begin
  71.   MyApp.Init('MyProgram');
  72.   MyApp.Run;
  73.   MyApp.Done;
  74. end.
  75.